import re
import json
rule = re.compile(r"""label:\s(.+?)?[\,|\}|\n\}]""")

with open("./main.js", "r", encoding="utf-8") as f:
    mainEN = f.read()

with open("./main.js", "r", encoding="utf-8") as f:
    mainZH = f.read()

mainEN = rule.findall(mainEN)
mainZH = rule.findall(mainZH)

dellist = [
    "i",
    "w",
    "null",
    "d",
    "s.label",
    "this.label",
    "a.label",
    "e",
    "y",
    "h",
    "u(g)",
    "ee(l)",
]
times = 0
while times <= 3:
    for e in mainEN:
        if e in dellist:
            mainEN.remove(e)
    for e in mainZH:
        if e in dellist:
            mainZH.remove(e)
    times += 1

d = dict(zip(mainEN, mainZH))
with open("main.json", "w") as w:
    json.dump(d, w, indent=2)
print(d)
print(len(d))
